<!DOCTYPE html>
<html  lang="en">
<head>
    <meta charset="utf-8">
<title>mac配置 - noback</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />



    <meta name="description" content="mac配置Mac OS 中如何优雅的创建定时任务mac 可以像linux一样使用crontab来使用定时任务.另外还有一个launchctl的工具 配置文件 xxx.plist   &lt;?xml version&#x3D;&quot;1.0&quot; encoding&#x3D;&quot;UTF-8&quot;?&gt; &lt;!DOCTYPE plist PUBLIC &quot;-&#x2F;&#x2F;Apple&#x2F;&#x2F;DT">
<meta property="og:type" content="article">
<meta property="og:title" content="mac配置">
<meta property="og:url" content="http://alpaca-h.gitee.io/2019/12/26/blog_back_new/%E8%AE%BE%E5%A4%87/%E8%BD%AF%E4%BB%B6%E9%85%8D%E7%BD%AE/mac%E9%85%8D%E7%BD%AE/index.html">
<meta property="og:site_name" content="noback">
<meta property="og:description" content="mac配置Mac OS 中如何优雅的创建定时任务mac 可以像linux一样使用crontab来使用定时任务.另外还有一个launchctl的工具 配置文件 xxx.plist   &lt;?xml version&#x3D;&quot;1.0&quot; encoding&#x3D;&quot;UTF-8&quot;?&gt; &lt;!DOCTYPE plist PUBLIC &quot;-&#x2F;&#x2F;Apple&#x2F;&#x2F;DT">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://alpaca-h.gitee.io/images/og_image.png">
<meta property="article:published_time" content="2019-12-26T04:27:09.000Z">
<meta property="article:modified_time" content="2019-12-27T09:25:48.513Z">
<meta property="article:author" content="Alpaca">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://alpaca-h.gitee.io/images/og_image.png">







<link rel="icon" href="/images/favicon.svg">


<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.7.2/css/bulma.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/androidstudio.css">


    
    
    
    <style>body>.footer,body>.navbar,body>.section{opacity:0}</style>
    

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
    

    
    

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">


    
    
    
    

<link rel="stylesheet" href="/css/back-to-top.css">


    
    

    
    
    
    

    
    
<link rel="stylesheet" href="/css/progressbar.css">
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

    
    
    

    
    
    
        <script async="" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    

    


<link rel="stylesheet" href="/css/style.css">
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="noback" type="application/atom+xml">
</head>
<body class="is-3-column">
    <nav class="navbar navbar-main">
    <div class="container">
        <div class="navbar-brand is-flex-center">
            <a class="navbar-item navbar-logo" href="/">
            
                <img src="/images/logo.svg" alt="mac配置" height="28">
            
            </a>
        </div>
        <div class="navbar-menu">
            
            <div class="navbar-start">
                
                <a class="navbar-item"
                href="/">Home</a>
                
                <a class="navbar-item"
                href="/archives/">Archives</a>
                
                <a class="navbar-item"
                href="/categories/">Categories</a>
                
                <a class="navbar-item"
                href="/tags/">Tags</a>
                
                <a class="navbar-item"
                href="/about/">About</a>
                
            </div>
            
            <div class="navbar-end">
                
                    
                    
                    <a class="navbar-item" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                    
                
                
                <a class="navbar-item is-hidden-tablet catalogue" title="Catalogue" href="javascript:;">
                    <i class="fas fa-list-ul"></i>
                </a>
                
                
                <a class="navbar-item search" title="Search" href="javascript:;">
                    <i class="fas fa-search"></i>
                </a>
                
            </div>
        </div>
    </div>
</nav>
    
    <section class="section">
        <div class="container">
            <div class="columns">
                <div class="column is-8-tablet is-8-desktop is-9-widescreen has-order-2 column-main"><div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <i class="fas fa-angle-double-right"></i>mac配置
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2019-12-26T04:27:09.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2019-12-26</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2019-12-27T09:25:48.513Z"><i class="far fa-calendar-check">&nbsp;</i>2019-12-27</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/%E8%AE%BE%E5%A4%87/">设备</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    6 minutes read (About 839 words)
                </span>
                
                
                <span class="level-item has-text-grey" id="busuanzi_container_page_pv">
                    <i class="far fa-eye"></i>
                    <span id="busuanzi_value_page_pv">0</span> visits
                </span>
                
            </div>
        </div>
        
        <div class="content">
            <h1 id="mac配置"><a href="#mac配置" class="headerlink" title="mac配置"></a>mac配置</h1><h2 id="Mac-OS-中如何优雅的创建定时任务"><a href="#Mac-OS-中如何优雅的创建定时任务" class="headerlink" title="Mac OS 中如何优雅的创建定时任务"></a>Mac OS 中如何优雅的创建定时任务</h2><p>mac 可以像linux一样使用crontab来使用定时任务.另外还有一个launchctl的工具</p>
<p><font color='red'>配置文件 xxx.plist</font>  </p>
<pre><code class="bash">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt; 
&lt;plist version=&quot;1.0&quot;&gt;
    &lt;dict&gt;
        &lt;!--Plist 名称，必须唯一--&gt; 
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;cn.rayjun..plist&lt;/string&gt; 
        &lt;!-- 指定要运行的程序的名称，可以是一个程序或者是一段脚本 --&gt;   
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;/path/to/programer&lt;/string&gt; 
        &lt;/array&gt;
        &lt;!-- 执行时间的指定 --&gt; 
        &lt;key&gt;StartCalendarInterval&lt;/key&gt; 
        &lt;dict&gt; 
            &lt;!--在第几分钟会被执行 --&gt;
            &lt;key&gt;Minute&lt;/key&gt;
            &lt;integer&gt;00&lt;/integer&gt;
            &lt;!-- 在第几个小时会被执行--&gt;
            &lt;key&gt;Hour&lt;/key&gt; 
            &lt;integer&gt;22&lt;/integer&gt; 
        &lt;/dict&gt;
        &lt;!-- 运行日志 --&gt;
        &lt;key&gt;StandardOutPath&lt;/key&gt;
        &lt;string&gt;/path/to/log/x.log&lt;/string&gt;
        &lt;!-- 错误日志 --&gt;
        &lt;key&gt;StandardErrorPath&lt;/key&gt; 
        &lt;string&gt;/path/to/err/x.err&lt;/string&gt;
    &lt;/dict&gt; 
&lt;/plist&gt; </code></pre>
<p>在 Plist 中，支持两种定时任务的设置：</p>
<ul>
<li>StartInterval：定义任务多长时间（单位，秒）执行一次</li>
<li>StartCalendarInterval：这个配置类似在 crontab 中的配置，指定具体的执行日期、星期、每月、每日的各个时间点，具体参照上面的配置文件。月份和天数的配置类似。</li>
</ul>
<p><font color='red'>存放点</font><br>在 Mac 系统中，可以将需要处理的事情都写在 plist 文件中，plist 是一个 xml 格式的文件。plist 文件根据不同的需要可以放在不同的目录底下。Mac OS X 中支持放 plist 的目录如下：</p>
<ul>
<li>/Library/LaunchDaemons: 系统启动后就会执行</li>
<li>/Library/LaunchAgents: 当用户登录系统后才会执行</li>
<li>~/Library/LaunchAgents: 用户自定义的 plist</li>
<li>/System/Library/LaunchAgents: 由 Mac OS X 为用户定义的任务</li>
<li>/System/Library/LaunchDaemons: 由 Mac OS X 定义的守护进程任务</li>
</ul>
<p><font color='red'>命令行</font></p>
<pre><code class="bash">launchctl load xx.plist # 启动程序
launchctl unload xx.plist # 停止程序</code></pre>
<h2 id="解决讨厌的-DS-Store"><a href="#解决讨厌的-DS-Store" class="headerlink" title="解决讨厌的.DS_Store"></a>解决讨厌的.DS_Store</h2><p>.DS_Store (Desktop Services Store) 是一种由苹果公司的 Mac OS X 操作系统所创造的隐藏文件，目的在于存贮目录的自定义属性，例如文件们的图标位置或者是背景色的选择。相当于 Windows 下的 desktop.ini</p>
<p><font color='red'>为什么要解决？</font><br>如果不处理，每次拷贝给你同事的文件里都会包含有这个文件，或者上传网页的时候，应该把这个文件删除比较妥当，因为里面包含了一些你不一定希望别人看见的信息。（尤其是网站，通过 .DS_Store 可以知道这个目录里面所有文件的清单，很多时候这是一个不希望出现的问题。）</p>
<pre><code class="php">&lt;?php //例子
　　$filepath = &quot;images&quot;;
　　$handle = opendir($filepath);
　　while (false != ($file = readdir($handle))) {
　　    if ($file != &quot;.&quot; &amp;&amp; $file != &quot;..&quot; &amp;&amp; $file != &quot;.DS_Store&quot; &amp;&amp; $file != &quot;index.html&quot; &amp;&amp; $file != &quot;index.htm&quot; &amp;&amp; $file != &quot;index.php&quot;) {
　　        if ($output) $output .= &quot;|&quot;;
　　        $output .= &quot;$file&quot;;
　　    }
　　}
　　closedir($handle);
　　echo &quot;&amp;files=$output&amp;&quot;; //输出遍历此文件夹所有的内容
?&gt; </code></pre>
<p><font color='red'>解决</font></p>
<ul>
<li>删除当前目录的.DS_Store<pre><code class="bash">find . -name &#39;*.DS_Store&#39; -type f -delete</code></pre>
</li>
<li>删除所有目录的.DS_Store<pre><code class="bash">sudo find / -name &quot;.DS_Store&quot; -depth -exec rm {} \;</code></pre>
</li>
<li>禁止.DS_Store生成<pre><code class="bash">defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE</code></pre>
</li>
<li>恢复.DS_Store生成<pre><code class="bash">defaults delete com.apple.desktopservices DSDontWriteNetworkStores</code></pre>
git上传忽略全局文件，并且在gitconfig中引入<br>```bash<br>touch ~/.gitigonre_global<h1 id="gitignore-global"><a href="#gitignore-global" class="headerlink" title=".gitignore_global"></a>.gitignore_global</h1>####################################<br>######## OS generated files ########<br>####################################<br>.DS_Store<br>.DS_Store?</li>
</ul>
<p><em>.swp<br>._</em><br>.Spotlight-V100<br>.Trashes<br>Icon?<br>ehthumbs.db<br>Thumbs.db<br>####################################<br>############# packages #############<br>####################################<br>*.7z<br>*.dmg<br>*.gz<br>*.iso<br>*.jar<br>*.rar<br>*.tar<br>*.zip </p>
<p>#.gitconfig<br>[filter “lfs”]<br>    required = true<br>    clean = git-lfs clean %f<br>    smudge = git-lfs smudge %f<br>[user]<br>    name = bingozb<br>    email = <a href="mailto:454113692@qq.com">454113692@qq.com</a><br>[core]<br>    excludesfile = /Users/bingo/.gitignore_global</p>
<p>```</p>

        </div>
        
            <ul class="post-copyright">
            <li><strong>本文标题：</strong><a href="http://alpaca-h.gitee.io/2019/12/26/blog_back_new/%E8%AE%BE%E5%A4%87/%E8%BD%AF%E4%BB%B6%E9%85%8D%E7%BD%AE/mac%E9%85%8D%E7%BD%AE/">mac配置</a></li>
            <li><strong>本文作者：</strong><a href="http://alpaca-h.gitee.io">Alpaca</a></li>
            <li><strong>本文链接：</strong><a href="http://alpaca-h.gitee.io/2019/12/26/blog_back_new/%E8%AE%BE%E5%A4%87/%E8%BD%AF%E4%BB%B6%E9%85%8D%E7%BD%AE/mac%E9%85%8D%E7%BD%AE/">http://alpaca-h.gitee.io/2019/12/26/blog_back_new/%E8%AE%BE%E5%A4%87/%E8%BD%AF%E4%BB%B6%E9%85%8D%E7%BD%AE/mac%E9%85%8D%E7%BD%AE/</a></li>
            <li><strong>发布时间：</strong>2019-12-26</li>
            <li><strong>版权声明：</strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="external nofollow" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处！
            </li>
            </ul>
        
        
        
        
    </div>
</div>





<div class="card card-transparent">
    <div class="level post-navigation is-flex-wrap is-mobile">
        
        <div class="level-start">
            <a class="level level-item has-link-grey  article-nav-prev" href="/2019/12/26/blog_back_new/Rust/rust%E5%9F%BA%E7%A1%80/2-rust%E7%8C%9C%E8%B0%9C%E6%B8%B8%E6%88%8F/">
                <i class="level-item fas fa-chevron-left"></i>
                <span class="level-item">rust猜谜游戏</span>
            </a>
        </div>
        
        
    </div>
</div>



</div>
                




<div class="column is-4-tablet is-4-desktop is-3-widescreen  has-order-1 column-left ">
    
        
<div class="card widget">
    <div class="card-content">
        <nav class="level" style="margin-bottom:1rem">
            <div class="level-item has-text-centered">
                <div>
                    
                        <img class="image is-96x96 has-mb-6" src="https://www.gravatar.com/avatar/e0f4032c0f2d1068ffffbaf93c0bef52?s=96" alt="Xinyu Liu">
                    
                    
                    <p class="is-size-4 is-block">
                        Xinyu Liu
                    </p>
                    
                    
                    <p class="is-size-6 is-block">
                        Alpha Lxy
                    </p>
                    
                    
                    <p class="is-size-6 is-flex is-flex-center has-text-grey">
                        <i class="fas fa-map-marker-alt has-mr-7"></i>
                        <span>Beijing, China</span>
                    </p>
                    
                </div>
            </div>
        </nav>
        <nav class="level menu-list is-mobile" style="margin-bottom:1rem">
            <div class="level-item has-text-centered is-marginless">
                <a href="/archives/">
                    <p class="heading">
                        Posts
                    </p>
                    <p class="title has-text-weight-normal">
                        40
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/categories/">
                    <p class="heading">
                        Categories
                    </p>
                    <p class="title has-text-weight-normal">
                        13
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/tags/">
                    <p class="heading">
                        Tags
                    </p>
                    <p class="title has-text-weight-normal">
                        0
                    </p>
                </a>
            </div>
        </nav>
        <div class="level">
            <a class="level-item button is-link is-rounded" href="https://www.github.com/AlphaLxy" target="_blank">
                <i class="fab fa-github"></i>&nbsp;&nbsp;Follow</a>
        </div>
        
        
    </div>
</div>

    
        
<div class="card widget column-left is-sticky" id="toc">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Catalogue
            </h3>
            <ul class="menu-list"><li>
        <a class="is-flex" href="#mac配置">
        <span class="has-mr-6">1</span>
        <span>mac配置</span>
        </a><ul class="menu-list"><li>
        <a class="is-flex" href="#Mac-OS-中如何优雅的创建定时任务">
        <span class="has-mr-6">1.1</span>
        <span>Mac OS 中如何优雅的创建定时任务</span>
        </a></li><li>
        <a class="is-flex" href="#解决讨厌的-DS-Store">
        <span class="has-mr-6">1.2</span>
        <span>解决讨厌的.DS_Store</span>
        </a></li></ul></li><li>
        <a class="is-flex" href="#gitignore-global">
        <span class="has-mr-6">2</span>
        <span>.gitignore_global</span>
        </a></li></ul>
        </div>
    </div>
</div>


    
    
        <div class="column-right-shadow is-hidden-widescreen ">
        
        </div>
    
</div>

                
            </div>
        </div>
    </section>
    <footer class="footer">
    <div class="container">
        <div class="level">
            <div class="level-start has-text-centered-mobile">
                <a class="footer-logo is-block has-mb-6" href="/">
                
                    <img src="/images/logo.svg" alt="mac配置" height="28">
                
                </a>
                <p class="is-size-7">
                &copy; 2020 Alpaca&nbsp;
                Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> & <a
                        href="http://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a>
                
                <br>
                <span id="busuanzi_container_site_uv">
                Visited by <span id="busuanzi_value_site_uv">0</span> users
                </span>
                
                </p>
            </div>
            <div class="level-end">
            
                <div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle">
                
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
                        
                        <i class="fab fa-creative-commons"></i>&nbsp;<i class="fab fa-creative-commons-by"></i>&nbsp;<i class="fab fa-creative-commons-nc"></i>&nbsp;<i class="fab fa-creative-commons-sa"></i>&nbsp;
                        
                    </a>
                </p>
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>&nbsp;
                        
                    </a>
                </p>
                
                </div>
            
            </div>
        </div>
    </div>
</footer>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/min/moment-with-locales.min.js"></script>
<script>moment.locale("en");</script>


    
    
    
    <script src="/js/animation.js"></script>
    

    
    
    
    <script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/js/lightgallery.min.js" defer></script>
    <script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js" defer></script>
    <script src="/js/gallery.js" defer></script>
    

    
    

<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/" target="_blank" rel="noopener">Update
            my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js" defer></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        });
    });
</script>


    
    
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/unpacked/MathJax.js?config=TeX-MML-AM_CHTML" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    MathJax.Hub.Config({
        'HTML-CSS': {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
});
</script>

    
    

<a id="back-to-top" title="Back to Top" href="javascript:;">
    <i class="fas fa-chevron-up"></i>
</a>
<script src="/js/back-to-top.js" defer></script>


    
    

    
    
    
    

    
    
    
    
    
    <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js" defer></script>
    <script src="/js/clipboard.js" defer></script>
    

    
    
    

    


<script src="/js/main.js" defer></script>

    
    <div class="searchbox ins-search">
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="Type something..." />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            CONTENT_URL: '/content.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script src="/js/insight.js" defer></script>
<link rel="stylesheet" href="/css/search.css">
<link rel="stylesheet" href="/css/insight.css">
    
</body>
</html>